package com.dazzle.system.controller;

import java.util.Locale;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;

@Controller
@RequestMapping("/system")
public class I18nController{
	@Resource
	private SessionLocaleResolver sessionLocaleResolver;
	
	@RequestMapping("/change_lan")
	public String list(HttpServletRequest request,HttpServletResponse response){
		String local = request.getParameter("local");
		if(local != null && !"".equals(local)){  
            if("zh-CN".equals(local)){  
//                sessionLocaleResolver.setLocale(request, response, Locale.CHINA);  
            	request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.CHINA);  
            }else if("en-US".equals(local)){  
//                sessionLocaleResolver.setLocale(request, response, Locale.getDefault());  
            	request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.ENGLISH);  
            }  
        }  
		return "redirect:/home.do";
	}
}